package com.guet.ltomanagement.controller;


import com.guet.ltomanagement.common.entities.ResultBody;
import com.guet.ltomanagement.entity.SysUnit;
import com.guet.ltomanagement.entity.SysUserUnit;
import com.guet.ltomanagement.service.SysUserUnitService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author sjj
 * @since 2023-03-07
 */
@RestController
@RequestMapping("/sys/user/unit")
public class SysUserUnitController extends BaseController {
    @Autowired
    private SysUserUnitService sysUserUnitService;

    @ApiOperation(value = "添加用户单位关系")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "sysUserUnit", value = "用户单位关系类", required = true, dataType = "SysUserUnit"),
    })
    @PostMapping("/add")
    public ResultBody add(@Validated @RequestBody SysUserUnit sysUserUnit)
    {
        return ResultBody.success(sysUserUnitService.add(sysUserUnit));
    }

    @ApiOperation(value = "删除用户单位关系")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "UserId", value = "用户ID", required = true, dataType = "Integer"),
            @ApiImplicitParam(name = "UnitId", value = "单位ID", required = true, dataType = "Integer")
    })
    @DeleteMapping("/delete")
    public ResultBody delete(@RequestParam Integer UserId, @RequestParam Integer UnitId)
    {
        return ResultBody.success(sysUserUnitService.delete(UserId, UnitId));
    }
}
